from emmongo import em_mongomanager as mongoManager
import tushare as ts
from LSTM.variableset import EMVar
import datetime

data = ts.get_k_data(code=EMVar.CODE_SH, index=True, ktype='D', start='2000-0-01',
                     end=datetime.datetime.now().strftime("%Y-%m-%d"))
data.set_index(data[EMVar.date], inplace='True')
for index, row in data.iterrows():
    mongoManager.db[mongoManager.COL_INDEX_HIS_DATA].update_one({EMVar.date:index, EMVar.code:dict(row)[EMVar.code]}, {'$set':row.to_dict()}, upsert=True)

